<?php /*a:1:{s:53:"C:\xampp\htdocs\application\index\view\user\user.html";i:1642349879;}*/ ?>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>文档列表 - 光年(Light Year Admin V4)后台管理系统模板</title>
<link rel="icon" href="favicon.ico" type="image/ico">
<meta name="keywords" content="LightYear,LightYearAdmin,光年,后台模板,后台管理系统,光年HTML模板">
<meta name="description" content="Light Year Admin V4是一个后台管理系统的HTML模板，基于Bootstrap v4.4.1。">
<meta name="author" content="yinqi">
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/static/js/jquery-confirm/jquery-confirm.min.css" rel="stylesheet">
<link href="/static/css/animate.min.css" rel="stylesheet">
<link href="/static/css/style.min.css" rel="stylesheet">
  <style>
    .avatar{
      width: 30px;
      height: 30px;
    }
  </style>
</head>

<body>
<div class="container-fluid p-t-15">
  
  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-toolbar d-flex flex-column flex-md-row">
          
          <form class="search-bar ml-md-auto" method="get" action="#!" role="form">
            <input type="hidden" name="search_field" id="search-field" value="title" />
            <div class="input-group ml-md-auto">
              <div class="input-group-prepend">
                <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="search-btn">标题</button>
                <div class="dropdown-menu" style="">
                  <a class="dropdown-item" href="#!" data-field="title">标题</a>
                  <a class="dropdown-item" href="#!" data-field="cat_name">栏目</a>
                </div>
              </div>
              <input type="text" class="form-control" name="keyword" placeholder="请输入名称">
            </div>
          </form>
        </div>
        <div class="card-body">
          
          <div class="table-responsive">
            <table class="table table-bordered">
              <thead>
                <tr>
                  <th>编号</th>
                  <th>用户名</th>
                  <th>头像</th>
                  <th>真实姓名</th>
                  <th>电话</th>
                  <th>email</th>
                  <th>简介</th>
                  <th>是否为评审教师</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
                <?php foreach($users as $user): ?>
                <tr>
                  <td><?php echo htmlentities($user['id']); ?></td>
                  <td><?php echo htmlentities($user['username']); ?></td>
                  <td>
                    <?php if($user['avatar']!=''): ?>
                    <img src="<?php echo htmlentities($user['avatar']); ?>" class="avatar">
                    <?php endif; ?>
                  </td>
                  <td><?php echo htmlentities($user['realname']); ?></td>
                  <td><?php echo htmlentities($user['phone']); ?></td>
                  <td><?php echo htmlentities($user['email']); ?></td>
                  <td><?php echo htmlentities($user['remark']); ?></td>
                  <td>
                    <?php if($user['state']==1): ?>
                      普通教师
                    <?php elseif($user['state']==2): ?>
                      评审教师
                    <?php elseif($user['state']==3): ?>
                      管理员
                    <?php else: ?>
                      未知
                    <?php endif; ?>
                  </td>
                  <td>
                    <div class="btn-group btn-group-sm">
                      <?php if($user['state']==1): ?>
                      <button class="btn btn-default" onclick="editOrDel(<?php echo htmlentities($user['id']); ?>,1)">设为评审教师</button>
                      <?php endif; ?>
                      <button class="btn btn-default" onclick="editOrDel(<?php echo htmlentities($user['id']); ?>,2)">删除用户</button>
                    </div>
                  </td>
                </tr>
                <?php endforeach; ?>
              </tbody>
            </table>
          </div>
          <?php echo $users; ?>
 
        </div>
      </div>
    </div>
  </div>
  
</div>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/popper.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/static/js/lyear-loading.js"></script>
<script type="text/javascript" src="/static/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="/static/js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/static/js/main.min.js"></script>
<script type="text/javascript" src="/static/js/msg.js"></script>
<script type="text/javascript">
  function editOrDel(id,type){
    $.confirm({
      title: '',
      content:'确认要执行该操作吗？',
      type: 'orange',
      typeAnimated: true,
      buttons: {
        confirm: {
          text: '确认',
          btnClass: 'btn-blue',
          action: function() {
            action(id,type);
          }
        },
        cancel: {
          text: '取消',
          action: function() {}
        }
      }
    });
  }
  function action(id,type){
    $.ajax({
      url: type==2 ? '/index/user/deluser' : '/index/user/powerTeacher',
      data:{
        id
      },
      method:"POST",
      dataType:"json",
      success:function (res){
        if(res.code){
          msgShow.success(res.msg);
          setTimeout(()=>{
            location.reload();
          },1000)
        }else{
          msgShow.error(res.msg)
        }
      }
    })
  }

</script>
</body>
</html>